package com.xm_jd.model.dao;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

import com.xm_jd.model.entitys.GoodsDetailVO;
import com.xm_jd.model.entitys.shoop;
import com.xm_jd.utils.BaseDao;

public class IndexDao{
		BaseDao<shoop> bdao = new BaseDao<>(shoop.class);
	
		/**
		 * ��ȡ������Ʒ�б�
		 * @return
		 */
		public List<shoop> getNewsList(int current,int pagesize){
			//��һ��Sql���
			String sql = "SELECT * FROM tb_shoop INNER JOIN tb_leibie ON tb_shoop.shoop_Sort=tb_leibie.`leibie_id`" 
					+" INNER JOIN tb_picture ON tb_shoop.`shoop_Id`=tb_picture.`picture_shoop_Id` where picture_Zcg=1 LIMIT ?,?";
			//�ڶ�,����BaseDao��ѯ
			return bdao.selectAll(sql, new Object[]{(current-1)*pagesize,pagesize});
		}
		
		
		/**
		 * ������е���Ʒ��¼��
		 * @return
		 */
		public int getTotalNews(){
			String sql = "SELECT count(*) FROM tb_shoop INNER JOIN tb_leibie ON tb_shoop.shoop_Sort=tb_leibie.`leibie_id`" ;
			return bdao.getCounts(sql);
		}
		
		/**
		 * ������ƷID��ѯ��Ʒ
		 * @param id
		 * @return
		 */
		public List<GoodsDetailVO> getByid(int id){
			BaseDao<GoodsDetailVO> ldao=new BaseDao<>(GoodsDetailVO.class);
			String sql="SELECT * FROM  WHERE shoop_Id=?";
			return ldao.selectAll(sql, new Object[]{id});		
		}
}
